<template>
  <div>
    <div style="width: 100%">
      <el-input placeholder="输入订单号" style="width: 250px" v-model="onum" />
      <el-input placeholder="输入床位" style="width: 250px" v-model="bnum" />
      <el-input
        placeholder="输入用户姓名"
        style="width: 250px"
        v-model="cname"
      />
      <el-select v-model="orderstatus" placeholder="订单状态">
        <el-option label="进行中" value="0"></el-option>
        <el-option label="待付款" value="1"></el-option>
        <el-option label="已完成" value="2"></el-option>
      </el-select>

      <el-button @click="getAllOrder" type="primary" icon="el-icon-search"
        >查询</el-button
      >
    </div>
    <br /><br />
    <el-table
      ref="multipleTable"
      :data="pageInfo.list"
      tooltip-effect="dark"
      style="width: 80%; margin: 0px auto"
    >
      <el-table-column prop="onum" label="订单编号" width="120"></el-table-column>
      <el-table-column prop="orderTime" label=" 下单时间" width="200"></el-table-column>
      <el-table-column prop="returnTime" label="结束订单" width="200"></el-table-column>
      <el-table-column prop="bed.bnum" label="床位" width="100"></el-table-column>
      <el-table-column prop="customer.cname" label="客户姓名" width="100"></el-table-column>
      <el-table-column prop="customer.phone" label="联系方式"></el-table-column>
      <el-table-column prop="payTime" label="付款时间" width="200"></el-table-column>
      <el-table-column prop="actualpay" label="实际付款" width="100"></el-table-column>
      <el-table-column prop="orderstatus" label="订单状态">
        <template slot-scope="scope">
          {{
            scope.row.orderstatus === 0
              ? "进行中"
              : scope.row.orderstatus === 1
              ? "待付款"
              : "已完成"
          }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.pageNum"
      :page-sizes="[3, 5, 8, 10]"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
    >
    </el-pagination>
  </div>
</template>
<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
<script>
import { getdepartmentOrder } from "@/api/departmentOrder.js";

export default {
  data() {
    return {
      pageInfo: {
        pageNum: 1,
        pageSize: 10,
      },
      onum: "",
      bnum: "",
      cname: "",
      orderstatus: "",
    };
  },
  methods: {
    getAllOrder() {
      getdepartmentOrder({
        pageNum: this.pageInfo.pageNum,
        pageSize: this.pageInfo.pageSize,
        onum: this.onum,
        bnum: this.bnum,
        cname: this.cname,
        orderstatus: this.orderstatus,
      }).then((res) => {
        if (res.data.code == 200) {
          this.pageInfo = res.data.data;
        }
        this.bnum = "";
        this.cname = "";
        this.orderstatus = "";
        this.onum = "";
      });
    },
    //val=改变之后的条目数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.pageInfo.pageNum = 1;
      this.getAllOrder();
    },
    //改变之后的当前页
    handleCurrentChange(val) {
      this.pageInfo.pageNum = val;
      this.getAllOrder();
    },
  },
  mounted() {
    this.getAllOrder();
  },
};
</script>
